import { reactive } from "vue";
import { getListApi } from "@/api/configCenter/outBoundAgent";
import { getAllCompanyApi } from "@/api/managementCenter/departmentPersonnel";
export const searchItemList: Array<SuperSearch.SearchItem> = [
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "代理商",
    keyName: "id",
    optionsRequest: getListApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  })
];

export const tableColumn: Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem> = [
  {
    type: "checkbox",
    field: "checkbox",
    minWidth: "50"
  },
  {
    field: "agent",
    title: "代理商",
    minWidth: "120"
  },
  {
    field: "companyName",
    title: "经营单位",
    minWidth: "120"
  },
  {
    field: "statementType",
    title: "账单类型",
    minWidth: "120",
    formatter: ({ cellValue }: any) => {
      if (cellValue === 1) return "代理对账单";
      else if (cellValue === 2) return "代理加收单";
      else return "-";
    }
  },
  {
    field: "payableAmount",
    title: "导入应付金额",
    minWidth: "120"
  },
  {
    field: "sum",
    title: "运单数",
    minWidth: "100"
  },
  {
    field: "createName",
    title: "对账人",
    minWidth: "90"
  },
  {
    field: "createTime",
    title: "账单导入日期",
    minWidth: "135",
    formatter: "formatDate"
  },
  {
    field: "status",
    title: "对账状态",
    minWidth: "90",
    renderSlot: "status"
  },
  {
    field: "action",
    title: "操作",
    minWidth: "120",
    fixed: "right",
    renderSlot: "action"
  }
];
